package top.lixunda.ecommerce.server.user.api.feign;

import com.baomidou.mybatisplus.extension.plugins.pagination.Page;
import io.swagger.annotations.Api;
import io.swagger.annotations.ApiOperation;
import org.springframework.cloud.openfeign.FeignClient;
import org.springframework.web.bind.annotation.*;
import top.lixunda.commerce.common.core.config.FeignConfig;
import top.lixunda.commerce.common.core.constants.ServiceIds;
import top.lixunda.commerce.common.core.entity.MessageObject;
import top.lixunda.common.validate.XumValid;
import top.lixunda.ecommerce.server.business.api.entity.dto.PageDTO;
import top.lixunda.ecommerce.server.user.api.entity.db.AccountDO;
import top.lixunda.ecommerce.server.user.api.entity.db.UserDetailDO;
import top.lixunda.ecommerce.server.user.api.entity.dto.AccountQueryDTO;

import java.util.List;

/**
 * 用户相关内部调用接口
 *
 * @author lixunda
 * @version time:2020/4/14 15:29
 */
@Api("用户相关内部调用接口，接口调用")
@FeignClient(value = ServiceIds.MIDDLE_USER, configuration = FeignConfig.class)
@RequestMapping("/feign/account")
public interface IFeignAccountController {

    /**
     * 根据id查询账户数据
     *
     * @param accountId 账户编号
     * @return 账户信息
     */
    @ApiOperation(value = "根据id查询账户数据", notes = "内部权限")
    @GetMapping("queryAccountById")
    MessageObject<AccountDO> queryAccountById(@RequestParam("accountId") String accountId);

    /**
     * 条件查询账户数据
     *
     * @param accountQueryDTO 条件查询信息
     * @return 账户列表
     */
    @ApiOperation(value = "条件查询账户数据", notes = "内部权限")
    @PostMapping("queryAccountByWrapper")
    MessageObject<List<AccountDO>> queryAccountByWrapper(
            @RequestBody @XumValid AccountQueryDTO accountQueryDTO);

    /**
     * 分页条件查询用户数据
     *
     * @param pageDTO 添加分页数据
     * @return 账户分页数据
     */
    @ApiOperation(value = "分页条件查询用户数据", notes = "内部权限")
    @PostMapping("queryAccountByPageWrapper")
    MessageObject<Page<AccountDO>> queryAccountByPageWrapper(
            @RequestBody @XumValid PageDTO<AccountDO, AccountQueryDTO> pageDTO);

    /**
     * 使用token进行登录
     *
     * @param token token字符串
     * @return 返回去除密码账户信息，登陆失败时返回Object为Null
     */
    @ApiOperation("loginByTokenString")
    @GetMapping("loginByTokenString")
    MessageObject<UserDetailDO> loginByTokenString(@RequestParam("token") String token);

}
